package com.deryun.tyl.controller;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.deryun.tyl.bean.Standard;
import com.deryun.tyl.bean.Standard;
import com.deryun.tyl.service.impl.StandardServiceImpl;

@Controller
@RequestMapping("standard")
public class StandardController {

	@Resource(name="standardServiceImpl")
	private StandardServiceImpl standardServiceImpl;
	
	@RequestMapping("/addStandard")
	public String addStandard(HttpServletRequest request,Standard standard){
		int result = standardServiceImpl.addStandard(request,standard);
		return "redirect:/ftoac/toLoadBzgf";
	}
	
	/***
	 * 获取所有政策法规
	 * @return
	 */
	@RequestMapping("/getAllStandard")
	public List<Standard> getAllStandard(){
		return standardServiceImpl.getAllStandard();
	}
	
	/***
	 * 删除制定政策法规
	 * @param id
	 * @return
	 */
	@RequestMapping("/deleteStandard")
	public String deleteStandard(int id){
		standardServiceImpl.deleteStandard(id);
		return "redirect:/ftoac/toLoadBzgf";
	}
	
	@RequestMapping("/modifyStandard")
	public String modifyStandard(Standard standard){
		System.out.println(standard.getResult());
		standardServiceImpl.modifyStandard(standard);
		return "redirect:/ftoac/toLoadXxgk";
	}
	
	@RequestMapping("/getStandardById")
	public String getStandardById(HttpServletRequest request,int id){
		Standard message = standardServiceImpl.getStandardById(id);
		request.setAttribute("message", message);
		return "success";
	}
	
	@RequestMapping("/setResult")
	public String setResult(Standard standard){
		System.out.println(standard.getResult());
		standardServiceImpl.setResult(standard);
		return "redirect:/ftoac/toLoadBzgf";
	}
}
